{% extends "base.html" %}

{% load tags %}

{% block title %}post search {% endblock %}

{% block body-title %} <h1>post search</h1> {% endblock %}
{% block style %}
table
{
border:1px solid black;
border-collapse:collapse;
width:100%;
}
th,td
{
border:1px solid black;
border-collapse:collapse;
word-wrap:break-word;
overflow:hidden;
}
{% endblock %}

{% block content %}
<form action="" method="GET">
<label>search: </label>
<input type="TEXT" name="q" value="{{q|escape }}" size="50">
<input type="submit" value="search">
</form>

{% if pl %}
    <p align="center"><b>total {{ total }} item{{ total|pluralize}}, {{ max_page }} page{{ max_page|pluralize}} .this is page {{ page }} from {{ item_from }}</b></p>

    <p align="right" >{% PostListUrlPages qs page max_page as pagelist%}&nbsp;&nbsp;&nbsp;</p>
    <table>
    <tr>
    <th width="3%">no</th>
    <th width="62%">title</th>
    <th width="3%">nr_reply</th>
    <th width="9%">crt_date</th>
    <th width="9%">upd_date</th>
    <th width="14%">author</th>
    </tr>

    {% for item in pl %}
        <tr>
        <td align="center">{{forloop.counter|add:item_from}} </td>
        <td>[{{item.sector.name}}]&nbsp;&nbsp;<a href="{% url post-url post_id=item.id page_from=1 %}">{% HighlightWords item.title q %}</a></td>
        <td align="center"> {{ item.nr_reply }}</td>
        <td align="center" > {{ item.crt_date|date:"y-m-d H:i" }}</td>
        <td align="center"> {{ item.upd_date|date:"y-m-d H:i" }}</td>
        <td align="center"> {{item.author}} </td>
        </tr>
    {% endfor %}

    </table>

    <p align="right" >{% PostListUrlPages qs page max_page as pagelist%}&nbsp;&nbsp;&nbsp;</p>

{% else %}
    <p>No post are available.</p>
{% endif %}
   <p align="center"><b><a href="{% url postlist%}">postlist</a></b></p>

{% endblock %}
